using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Web.Caching;

public class StringHTML {
    public static string getHTML(string filename) {
        string output = string.Empty;

        try {
            string cacheKey = "G.HTML." + filename;

            Cache cache = System.Web.HttpRuntime.Cache;

            if (cache.Get(cacheKey) != null) {
                output = cache.Get(cacheKey) as string;
            }
            else {
                StreamReader sr = new StreamReader(new FileStream(HttpContext.Current.Server.MapPath("~/tpl/" + filename + ".tpl"), FileMode.Open, FileAccess.Read));
                output = sr.ReadToEnd();
                sr.Close();

                cache.Insert(cacheKey, output, null, DateTime.Now.AddMinutes(5), TimeSpan.Zero, CacheItemPriority.High, null);
            }
        }
        catch {
        }
        return output;
    }
}
